using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Framework;
using System.IO;

namespace BizTalk.BuildGenerator.Tasks.BAM
{
    /// <summary>
    /// Backs up the definition file so if something has been incorrectly configured then
    /// the original is still there to fix it with
    /// </summary>
    public class BackupDefinitionFile : BaseBMTask
    {
        private string _OutputFilePath;
        private string _DefinitionFilePath;

        /// <summary>
        /// The path to the definition file
        /// </summary>
        [Required]
        public string DefinitionFilePath
        {
            get { return _DefinitionFilePath; }
            set { _DefinitionFilePath = value; }
        }
        /// <summary>
        /// The path to the file where this will be placed
        /// </summary>
        [Required]
        public string OutputFilePath
        {
            get { return _OutputFilePath; }
            set { _OutputFilePath = value; }
        }
        /// <summary>
        /// Executes the task
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            File.Copy(this._DefinitionFilePath, this._OutputFilePath, true);
            return true;
        }
    }
}
